package com.xy.breakfast.service;

import com.xy.breakfast.entity.Clients;
import com.xy.breakfast.entity.Orders;
import com.xy.breakfast.mapper.OrdersMapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.logging.Logger;

//订单服务
@Service
public class OrdersService {

    @Autowired
    OrdersMapper ordersMapper;

    java.util.logging.Logger logger = Logger.getLogger(this.getClass().getName());

    //保存订单
    public void save(Orders o){
        if(o.getNum()<=0){
            logger.info("购买的数量必须为正数");
            return;
        }
        ordersMapper.save(o);
    }
    //获取客户订单
    public List<Orders> getByClientsId(int clientsId){
        return ordersMapper.getByClientsId(clientsId);
    }

    //统计每个小时订单的数量
    public List<Map<String,String>> getOrdersNumGroupByHour(){
        return ordersMapper.getOrdersNumGroupByHour();
    }

    public List<Map<String,Object>> getOrdersByTypesIdDay(){
        return ordersMapper.getOrdersByTypesIdDay();
    };

    public List<Map<String,Object>> getOrdersByTypesIdHour() {
        return ordersMapper.getOrdersByTypesIdHour();
    };

    //    不同类型销售比例图
    public List<Map<String,Object>> getOrdersByNum(){
        return ordersMapper.getOrdersByNum();
    };
}
